//
//  HeartRateHistoryDetailViewModel.swift
//  DaRings
//
//  Created by HFY on 2022/11/21.
//

import UIKit
import MYModule

open class SingleHeartRateProvider: NSObject {
    
    public var detail: SingleHeartRateDetailModel?
   
    // 最近7次心率值
    public var lastSevenTimeHearts: [SingleHeartRateModel]?
    
    
    public init(heartRateModel: SingleHeartRateModel?) {
        super.init()
        
        guard let heartRateModel = heartRateModel else {
            return
        }
 
        detail = SingleHeartRateDetailModel(heartRateModel: heartRateModel)
        
        var lastSevenTimesModels = SingleHeartRateModel.sevenTimesModel(from: heartRateModel.end)
        if lastSevenTimesModels.count < 7 {
            
          let emptyData = (lastSevenTimesModels.count ..< 7).map { _ in SingleHeartRateModel() }
            
            lastSevenTimesModels.append(contentsOf: emptyData)
            
        }
    
        /// 展示 是从右到 左
        lastSevenTimeHearts = lastSevenTimesModels.map { $0 }.reversed()
        
        
    }
    


}
